const pageTo = (url : string) => {
	try {
		uni.navigateTo({
			url: url,
			animationType: "zoom-fade-out"
		});
	} catch (e) {
		console.log('e====>>>', e);
	}

}
function getDate(date_text : string = 'day', type ?: string) : string {
	const date = new Date();

	let year : string | number = date.getFullYear();
	let month : string | number = date.getMonth() + 1;
	let day : string | number = date.getDate();

	let hours : string | number = date.getHours();
	let minutes : string | number = (date.getMinutes() + '').length === 1 ? '0' + date.getMinutes() : date.getMinutes();
	let seconds : string | number = (date.getSeconds()+'').length === 1 ? '0' + date.getSeconds() : date.getSeconds();

	if (type == 'start') {
		year = year - 10;
	} else if (type == 'end') {
		year = year + 10;
	}
	month = month > 9 ? month : '0' + month;;
	day = day > 9 ? day : '0' + day;
	if (date_text == 'month') {
		return `${year}-${month}`;
	} else if (date_text == 'year') {
		return `${year}`;
	} else if (date_text == 'time') {
		return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
	}


	return `${year}-${month}-${day}`;
}

function deleteEmpty(params) {
	for (var key in params) {
		if (params[key] === null || params[key] == '') delete params[key]
	}
}

// 动态转换字符串
function unicodeToChar(escapeStr) {
	try {
		const hex = escapeStr.replace(/\\u|"/g, ''); // 提取 e656
		return String.fromCodePoint(parseInt(hex, 16));
	} catch (error) {
		console.log(error);
		return '\ue656'
	}

}
export {
	pageTo, getDate, unicodeToChar, deleteEmpty
}